/*
 *  Author : Thanh Pham
 *  Create on : 14/9/2013
 */
package ConnectMng;

import java.sql.Connection;
import java.sql.DriverManager;

public class ConnectMng {
	private static Connection connection;
	
	// method getConnection() use to connect to mysql server database
    public static Connection getConnection(){
    	try{
    		Class.forName("com.mysql.jdbc.Driver");
    		connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/ServiceDirectory","root","12345678");
    		System.out.println(" Connected ");
    	}catch(Exception ex){
    		System.out.println(" Connect fail. Error : "+ex.getMessage());
    	}
    	return connection;
    }
    
 // method getConnectionSQLSERVER() use to connect to sql server database
    public static Connection getConnectionSQLSERVER(){
    	try{
    		Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
    		connection = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;DatabaseName=ServiceDirectory","sa","12345678");
    		System.out.println(" Connected ");
    	}catch(Exception ex){
    		System.out.println(" Connect fail. Error : "+ex.getMessage());
    	}
    	return connection;
    }    
}
